﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>命名插槽</title>
</head>
<body>
    <div id="app">
        <page-layout>
            <template #header>
                <h2 align="center">Header插槽</h2>
            </template>
            <template v-slot:main>
                <h3>Main插槽</h3>
                <p>这是Main插槽的内容。</p>
            </template>
            <template v-slot:footer>
                <p>这是Footer插槽的内容。</p>
            </template>
        </page-layout>
    </div>
<!--引入vue文件-->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
    const vm = Vue.createApp({ });
    vm.component('page-layout', {
        template: `
            <div class="container">
                <header>
                    <slot name="header"></slot>    
                </header>
                <main>
                    <slot name="main"></slot>    
                </main>
                <footer>
                    <slot name="footer"></slot>    
                </footer>
            </div>
        `
    });

    vm.mount('#app');
</script>
</body>
</html>
